@extends('admin.layout.global')

@section('css-plugins')
    <link href="{{ asset('style/plugins/bootstrap-switch/css/bootstrap3/bootstrap-switch.min.css') }}" rel="stylesheet">
    <link href="{{ asset('style/plugins/toastr/toastr.min.css') }}" rel="stylesheet">
@endsection

@section('css')
    <link href="{{ asset('style/admin/css/custom.css') }}" rel="stylesheet">
    <style>
        .pagination {
            margin: 0 0;
        }
    </style>
@endsection

@section('js-plugins')
    <script src="{{ asset('style/plugins/bootstrap-switch/js/bootstrap-switch.min.js') }}"></script>
    <script src="{{ asset('style/plugins/toastr/toastr.min.js') }}"></script>
@endsection

@section('js')
    <script>
        $(function(){
            toastr.options = {
                "progressBar": true,
                "positionClass": "toast-top-right",
                "timeOut": "1200",
            }
            $("[type='checkbox']").bootstrapSwitch();

            $("[type='checkbox']").on('switchChange.bootstrapSwitch', function(event, state) {
                var id = $(this).data('id');
                var display = 0;
                if(state)
                {
                    display = 1;
                }
                $.ajax({
                    url: "{{ action('Admin\MenuController@postDisplay') }}",
                    data: { id:id,display:display,_token:'{{ csrf_token() }}'},
                    type:'post',
                    success: function (data) {
                        var jsonData = JSON.parse(data);
                        if (jsonData.code)
                        {
                            toastr.success(jsonData.message);
                        } else {
                            toastr.error(jsonData.message);
                        }
                    }
                })
            });
        });
    </script>
@endsection

@section('content')
    <div class="body-content animated fadeIn">
        <div class="row">
            <div class="col-md-12">

                <!-- Start basic color table -->
                <div class="panel">
                    <div class="panel-heading">
                        <div class="pull-left">
                            <a href="{{ action('Admin\AdminMemberController@getAdd') }}" class="btn btn-success btn-sm"><i class="fa fa-user-plus"></i> {{ getLang('Tips', 'create') }}</a>
                        </div>
                        <div class="clearfix"></div>
                    </div><!-- /.panel-heading -->
                    <div class="panel-body no-padding">
                        <div class="table-responsive" style="margin-top: -1px;">
                            <table class="table table-striped table-success">
                                <thead>
                                <tr>
                                    <th class="text-center border-right" style="width: 5%">{{ getLang('fieldsAdminMember', 'id') }}</th>
                                    <th>{{ getLang('fieldsAdminMember', 'nickname') }}</th>
                                    <th>{{ getLang('fieldsAdminMember', 'username') }}</th>
                                    <th>{{ getLang('fieldsAdminMember', 'group') }}</th>
                                    <th>{{ getLang('fieldsAdminMember', 'email') }}</th>
                                    <th>{{ getLang('fieldsAdminMember', 'lastLogin') }}</th>
                                    <th class="text-center" style="width: 12%;">{{ getLang('Tips', 'operation') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($members as $v)
                                    <tr>
                                        <td class="text-center border-right">{{ $v->id }}</td>
                                        <td>
                                            <img src="{{ action('ImgController@getMember', ['uid' => $v->id, 'sourceName' => $v->thumb, 'size' => '20x20']) }}" width="22" alt="{{ $v->realName ? $v->realName : $v->name }}">
                                            <span>{{ $v->realName ? $v->realName : $v->name }}</span>
                                        </td>
                                        <td>{{ $v->name }}</td>
                                        <td><span class="label" style="background-color: {{ $GROUP[$v->groupID]->color }}">{{ $GROUP[$v->groupID]->name }}</span></td>
                                        <td>{{ $v->email }}</td>
                                        <td>{{ $v->updated_at }}</td>
                                        <td class="text-center">
                                            <a href="{{ action('Admin\AdminMemberController@getEdit', ['id' => $v->id]) }}" class="btn btn-primary btn-xs" data-toggle="tooltip" data-placement="top" data-original-title="{{ getLang('Tips', 'edit') }}"><i class="fa fa-pencil"></i></a>
                                            <button data-url="{{ action('Admin\AdminMemberController@getDel', ['id' => $v->id]) }}" data-tips='{{ getLang('Tips', 'isDelete') }} : {{ $v->realName ? $v->realName : $v->name }}' class='btn btn-danger btn-xs delete-table' data-toggle="tooltip" data-placement="top" data-original-title="{{ getLang('Tips', 'delete') }}"><i class="fa fa-times"></i></button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div><!-- /.table-responsive -->
                    </div><!-- /.panel-body -->
                    <div class="panel-footer">
                        <div class="row">
                            <div class="col-md-12">
                                <div style="text-align: center">
                                    {!! $members->render() !!}
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- /.panel -->
                <!--/ End basic color table -->

            </div><!-- /.col-md-12 -->
        </div>
    </div>
@endsection